import { AbstractMesh, Scene, Vector3 } from '@babylonjs/core'

export interface Anchor {
  name: string
  type: 'tag' | 'scene'
  position: Vector3
}

export interface SceneOption {
  name: string
  asset: string
  camera: Vector3
  anchors: Anchor[]
}

export interface Option {
  id: string | number
  scenes: SceneOption[]
}

const createOptionJson = (scene: Scene, anchors: any) => {
  const camera = scene.activeCamera
  if (!camera) return

  const option: SceneOption = {
    name: 'testoption',
    asset: 'assets/room3.jpg',
    camera: camera.position,
    anchors: []
  }

  option.anchors = anchors.map((anchor: any) => {
    return {
      name: anchor.name,
      position: anchor.position
    }
  })

  console.log(option)

  return JSON.stringify(option)
}

export default createOptionJson
